<?php
echo $this->Html->css('admin/admin_members_index');

$category_id = null;

foreach ($categories as $category) {
    if ($category['category']['default'] == '1') {
        $category_id = $category['category']['id'];
    }
}
?>
<div style="position: absolute; top: 0px; bottom: 0px; overflow: hidden">
<header class="b-b bg-white-only">
    <div class="row p-sm p-l">

        <div class="col-md-4">

            <span class="font-bold">Showing:</span>

            <div class="select btn-group" data-resize="auto" id="category_select">
                <button class="btn btn-sm btn-success dropdown-toggle" data-toggle="dropdown" style="width: 200px; overflow: hidden;">
                    <i class="fa fa-dot-circle-o pull-left m-l-xs"></i>
                    <span class="dropdown-label pull-left text-left text-ellipsis"></span>
                    <i class="fa fa-caret-down pull-right"></i>
                </button>
                <ul class="dropdown-menu text-sm">
                    <li data-value="-1" data-add-label="Member"> 
                        <a href="#">
                            <i class="fa fa-dot-circle-o"></i>
                            All Members
                        </a>
                    </li>
                    
                    <?php
                    foreach ($categories as $category) {
                        $selected = '';
                        if( $category['category']['default'] == "1" ) {
                            $selected = "data-selected='true'";
                        }
                        ?>
                        <li data-value="<?php echo $category['category']['id']; ?>" data-add-label="<?php echo isset($category['settings']['add_type_label']) ? $category['settings']['add_type_label'] : 'Member'; ?>" <?php echo $selected; ?> > 
                            <a href="#">
                                <i class="fa fa-dot-circle-o"></i>
                                <?php echo $category['category']['name']; ?>
                            </a>
                        </li>
                    <?php } ?>
                </ul>
            </div>
            
            <button class="btn btn-sm btn-success hidden"><i class="fa fa-plus"></i></button>
        </div>

        <div class='col-md-4'>
            <form id="member-search-form" class="form-inline" action="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'find_member')); ?>" class="form-horizontal">
                <div class="input-group m-r-sm">
                    <input type="text" id="member-search" class="form-control input-sm pull-right" placeholder="Find Member By ID, Name, Email or Phone Number" />
                    <div class="input-group-btn">
                        <button type="submit" id="search-btn" class="btn btn-sm btn-info"><i class="fa fa-search"></i></button>
                        <button type="reset" id="clear-btn" class="btn btn-sm btn-white"><i class="fa fa-ban"></i></button>
                    </div>
                </div>

                <input type='hidden' id='member-search-type' value='<?php echo $category_id; ?>' />
            </form>
        </div>
    </div>

</header> 


<section  class="hbox stretch">
    <aside class="aside-sm bg-white lter b-r" style="width: 27%;">
        <section class="vbox stretch">

            <header class="b-b">
                <div class="row p-sm" style="padding-bottom: 12px;">
                    <div class="col-sm-4">
                        <input id="checkall" type="checkbox" style="margin-left: 7px;"/>

                        <div class="btn-group">
                            <button class="btn dropdown-toggle btn-sm btn-white sort_btn" data-toggle="dropdown" title="Sort List">
                                <i class="fa fa-arrow-down"></i>
                                <span class="caret"></span>
                            </button>

                            <ul class="dropdown-menu">
                                <li><a id="sort-menu-recent" data-sort-order="recent" class="sort_menu" href="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'members_list', $category_id, 'recent')); ?>"><i class="fa fa-arrow-down"></i> Recent First</a></li>
                                <li><a id="sort-menu-alpha" data-sort-order="alpha" class="sort_menu" href="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'members_list', $category_id, 'alpha')); ?>"><i class="fa fa-list-ol"></i> Alphabetical</a></li>
                            </ul>
                        </div>
                    </div>

                    <div class="col-sm-8"> 

                        <div class="btn-group pull-right">

                            <button class="btn btn-sm btn-white dropdown-toggle" data-toggle="dropdown" title="Bulk Actions For Multiple Selected Records">
                                <i class="fa fa-cog"></i>
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu pull-right text-sm">
                                <li>
                                    <a id="delete-menu" href="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'removeMember')); ?>">
                                        <i class="fa fa-ban"></i> Delete Selected
                                    </a>
                                </li>

                                <li class="divider"></li>
                                
                                <li>
                                    <a id="change-category" href="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'change_category')); ?>">
                                        <i class="fa fa-refresh"></i> Change Category
                                    </a>
                                </li>

                                <li class="divider"></li>
                                <li>
                                    <a id="send-sms" href="<?php echo $this->Html->url(array('controller' => 'sms', 'action' => 'instant_message_popup')); ?>">
                                        <i class="fa fa-envelope-o"></i> Send SMS
                                    </a>
                                </li>
                            </ul>
                        </div>

                        <div class="btn-group pull-right m-r-xs">
                            <button href='<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'member_profile')); ?>' class="btn btn-sm btn-white" id="add_btn" data-category-id="<?php echo $category_id; ?>" title="Add New Member">
                                <i class="fa fa-plus"></i> Add Member <?php //echo ucfirst($category_id);             ?>
                            </button>
                        </div>
                    </div>
                </div>
            </header>

            <section id="list-table-content" class="scrollable" style="top: 54px;">
                <div class="panel" id="table-view" style="border: none; box-shadow: none;" data-url="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'members_list', $category_id, 'recent')); ?>">

                    <div class="panel-body" style="padding: 1px;">
                        <div id='table_view' class="row-fluid scroll-y">
                            <div class='scroll-block'>
                                <table id = "list-table" class = "table table-condensed table-striped">
                                    <tbody>

                                    </tbody>
                                </table>


                            </div>
                        </div>
                    </div>
                </div>

                
            </section>


        </section>
    </aside>

    <aside class="aside-xl bg-white-only" style="width: 73%;">
        <section class="vbox" id="profile-view">
            <div>
                <header class="b-b p-sm">
                    <div class="row">
                        <div class="col-lg-6" id="profile-view-title">
                            <p class="m-b-sm" style="font-weight: bold; font-size: 16px;">&nbsp;</p>
                        </div>

                        <div class="col-lg-6" id="edit_btn_group">
                            <div class="btn-group pull-right">
                                <button class="btn btn-sm btn-info" id="edit_btn" data-url="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'member_profile')); ?>">
                                    <i class="fa fa-pencil"></i> Edit Profile
                                </button>
                            </div>
                        </div>
                    </div>
                </header>

                <section id="profile_view_pane" class="scrollable">
                    <div class="content">
                        <div style='width: 600px; margin: 40px auto;'>
                            <div class='alert alert-info'>
                                <h3>Nothing To See Here</h3>
                                <p style='font-size: 16px;'>Use the <b><i class="fa fa-plus"></i> Add</b> button on the left pane to create a membership profile to begin</p>
                            </div>
                        </div>
                    </div>

                    <div id="loader_overlay">
                        <?php echo $this->Html->image('loaders/loader_128x.gif'); ?>
                    </div>
                </section>
            </div>
        </section>
    </aside>

</section>
</div>

<input type="hidden" id="remove_phone_number_url" value="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'removePhoneNumber')); ?>" />
<input type="hidden" id="remove_email_url" value="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'removeEmail')); ?>" />
<input type="hidden" id="member_list_url" value="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'members_list')); ?>" />
<input type="hidden" id="member_list_sort_order" value="recent" />
<input type="hidden" id="member_list_category_id" value="<?php echo $category_id; ?>" />
<input type="hidden" id="total_members" value="<?php echo $total_members; ?>" />

<?php echo $this->element('single_file_upload_manager'); ?>

<?php echo $this->element('members/admin/images_view'); ?>
<?php echo $this->element('single_file_upload_manager'); ?>

<?php
echo $this->Html->script('app/views/organisations/members.js');
